package web;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@WebServlet("/CheckImgServlet1")
public class CheckImgServlet1 extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public CheckImgServlet1() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		HttpSession session = request.getSession();
		String checkcode=(String) session.getAttribute("checkcode_session");
		String checkodeInput = request.getParameter("checkcodeinput");
		
		System.out.println(checkcode+":"+checkodeInput);
		boolean isTrue=false;
		if(checkcode.equals(checkodeInput)) {
			isTrue=true;
		}
		System.out.println(isTrue);
		response.setContentType("text/plain;charset=utf-8");
		response.getWriter().write("{\"isTrue\": "+isTrue+"}");
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
